; Global descriptor table
gdt_start:

gdt_null:	; The null descriptor
  dd 0x0
  dd 0x0

gdt_code:	; The code segment descriptor
  ; base=0x0, limit=0xfffff
  ; flags: (present)1 (privilege)00 (descriptor type)1 -> 1001b
  ; (code)1 (conforming)0 (readable)1 (accessed)0 -> 1010b
  ; (granularity)1 (32-bit default)1 (64bit segmentation)0 (AVL)0 -> 1100b
  dw 0xffff 	; Limit (bits 0-15)
  dw 0x0	; Base (bits 0-15)
  db 0x0	; Base (bits 16-23)
  db 10011010b	; flags + type flags
  db 11001111b  ; flags + Limit (bits 16-19)
  db 0x0	; Base (bits 24-31)

gdt_data:	; The data segment descriptor  
  ; Same as code segment except for the type flags:
  ; type flags: (code)0 (expand down)0 (writable)1 (accessed)0 -> 0010b
  dw 0xffff	; Limit (bits 0-15)
  dw 0x0	; Base (bits 0-15)
  db 0x0 	; Base (bits 16-23)
  db 10010010b  ; flags + type flags
  db 11001111b  ; flags + Limit (bits 16-19)
  db 0x0	; Base (bits 24-31)

gdt_end:


; GDT descriptor
gdt_descriptor:
  dw gdt_end - gdt_start - 1
  dd gdt_start


CODE_SEG equ gdt_code - gdt_start
DATA_SEG equ gdt_data - gdt_start
